#include "cam_protocol.h"
#include "cam_socket.h"

int SendCommandTakePhoto(void* contextPtr);
void RespondTakePhoto(const char* message,void* contextPtr);

static CamProtocolEvent g_event[] =
{
    {CAM_PROTOCOL_TAKEPHOTO,SendCommandTakePhoto,RespondTakePhoto},
};



void HandleEvent(CamProtocol &event, const char *message, void *contextPtr)
{

}




//发送拍照指令
int SendCommandTakePhoto(void* contextPtr)
{
    TakePhotoContext *context = (TakePhotoContext*)contextPtr;
    // 待发送的十六进制数据（原始数据）
    unsigned char hex_data[] = {
        0xFE, 0x55, 0x01, 0x00, 0xFF, 0x01, 0x02, 0x1E, 0x00, 0x03,
        0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBD, 0xCC
    };

    //发送拍照指令
    SendDataByUDP(hex_data,sizeof(hex_data));
    return 0;
}

int SendCommandSetCameraMode(void* contextPtr)
{
    // 设置拍照模式
    unsigned char hex_data[] = {
        0xFE, 0x55, 0x01, 0x00, 0x04, 0x01, 0x02, 0x1E, 0x08, 0x03, 0x00, 0x02, 0x00, 0x00, 0xBE, 0x56
    };

    SendDataByUDP(hex_data,sizeof(hex_data));
    return 0;
}


void RespondTakePhoto(const char* message,void* contextPtr)
{
    //处理拍照指令的回调函数

}

// int main(int argc, char** argv)
// {
//     //初始化socket
//     cam_socket_init();
//     //发送拍照指令
//     SendCommandTakePhoto(nullptr);
//     while(1);
// }